/**
 * @author: yasen
 * @time: 2022/10/11 16:18
 * @email: yasen@yasenstudio.com
 */
package org.example;

import java.io.FileReader;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

public class StudioMysqlConnection {
    private Connection connection;
    public StudioMysqlConnection() {
        Properties properties = new Properties();
        try {
            properties.load(new FileReader("./db.properties"));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        Connection conn = null;
        try {
            conn = DriverManager.getConnection(
                    properties.getProperty("url"),
                    properties.getProperty("username"),
                    properties.getProperty("password"));
            this.connection = conn;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
    public Connection getConnection() {
        return connection;
    }
}
